package pe.com.cotelasa.common.printer;

public class PrinterUtility {
	
	private static String ESPACIO_BLANCO = " ";

	public static String espaciosBlanco(int parmLen) {
		StringBuffer string = new StringBuffer();
		for (int i = 0; i < parmLen; i++)
			string.append(" ");
		return string.toString();
	}

	public static String alignRight(String pString, int pLength) {
		String vString = new String();
		int vLength;
		StringBuffer addSb = new StringBuffer(pLength);
		if (pString.length() > pLength)
			vString = pString.substring(0, pLength);
		else {
			vLength = pLength - pString.length();
			while(vLength > 0){
				addSb.append(ESPACIO_BLANCO);
				vLength--;
			}
			addSb = addSb.append(pString);
			vString = addSb.toString();
		}

		return vString;
	}
	
	
	public static String alignLeft(String pString, int pLength) {
		String vString = new String();
		int vLength;
		StringBuffer addSb = new StringBuffer(pLength);
		if (pString.length() > pLength)
			vString = pString.substring(pString.length()-pLength, pLength);
		else {
			vLength = pLength - pString.length();
			addSb = addSb.append(pString);
			while(vLength > 0){
				addSb.append(ESPACIO_BLANCO);
				vLength--;
			}
			vString = addSb.toString();
		}

		return vString;
	}
}
